Option Strict Off
Option Explicit On
Friend Class NameCollection
	
	Private m_Col As New Collection
	Public Sub Add(ByVal Name As String, Optional ByVal Before As Object = Nothing, Optional ByVal After As Object = Nothing)
		
		Dim Element As New NameElement
		Dim idx As Short
		
		'If both specified then error
		'only one can be specified
		'UPGRADE_NOTE: IsMissing() was changed to IsNothing(). Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1021"'
		If Not (IsNothing(Before) Or IsNothing(After)) Then
			Err.Raise(vbObjectError + 12,  , "Can not specify both parameters 'Before' and 'After'")
			Exit Sub
		End If
		
		'Set the Properties
		Element.Name = Name
		
		'UPGRADE_NOTE: IsMissing() was changed to IsNothing(). Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1021"'
		If IsNothing(Before) And IsNothing(After) Then
			m_Col.Add(Element, Name)
		ElseIf IsNothing(After) Then 
			m_Col.Add(Element, Name, Before)
            'UPGRADE_NOTE: IsMissing() was changed to IsNothing(). Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1021"'
        ElseIf IsNothing(Before) Then
            m_Col.Add(Element, Name, , After)
        End If
        Exit Sub
		
	End Sub
	Public Sub Clear()
		
		Dim i As Short
		
		For i = 1 To Count
			Remove(1)
		Next i
		
	End Sub
	Public ReadOnly Property Count() As Short
		Get
			Count = m_Col.Count()
		End Get
	End Property
	Public ReadOnly Property Exists(ByVal Value_Renamed As String) As Boolean
		Get
			
			Dim i As Short
			
			For i = 1 To Count
				If StrComp(Item(i).Name, Value_Renamed, CompareMethod.Text) = 0 Then
					Exists = True
					Exit Property
				End If
			Next i
			Exists = False
			
		End Get
	End Property
	Default Public ReadOnly Property Item(ByVal idx As Object) As NameElement
		Get
			Item = m_Col.Item(idx)
		End Get
	End Property
	Public Function FileSize() As Integer
		
		Dim i As Short
		Dim lSize As Integer
		
		For i = 1 To Count
			lSize = lSize + Item(i).FileSize
		Next i
		FileSize = lSize
		
	End Function
	
	Public Sub Remove(ByVal idx As Object)
		m_Col.Remove(idx)
	End Sub
	'UPGRADE_NOTE: Class_Terminate was upgraded to Class_Terminate_Renamed. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1061"'
	Private Sub Class_Terminate_Renamed()
		'UPGRADE_NOTE: Object m_Col may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1029"'
		m_Col = Nothing
	End Sub
	Protected Overrides Sub Finalize()
		Class_Terminate_Renamed()
		MyBase.Finalize()
	End Sub
End Class